﻿// Oil Temperature and Pressure    - 油温油压表

#include "TempPress.h"

void drawOTP(double circle_x, double circle_y, double circle_r, double angle,double angle2)
{
    //double circle_x, circle_y, circle_r;//圆心和半径
    //circle_x = 600, circle_y = 400, circle_r = 100;
//    initgraph(1200, 800, INIT_RENDERMANUAL);//手动渲染，避免闪烁
    ege_enable_aa(true);//抗锯齿
    //    setbkcolor(WHITE);//背景色白色
    {
        if (angle < 75) {
            angle = 75;
        }

        if (angle > 245) {
            angle = 245;
        }

        if (angle2 < 0) {
            angle2 = 0;
        }

        if (angle2 > 115) {
            angle2 = 115;
        }
    }//限制范围
    
    {
        angle = (angle - 175) * -5.4 * M_PI / 2025;
        angle2 = (angle2 - 60) * 24 * M_PI / 5400;
    }//转换公式

    

    g3(circle_x, circle_y, circle_r);//图形
    leftzhizhen1(circle_x, circle_y, circle_r, angle);//左指针
    rightzhizhen1(circle_x, circle_y, circle_r, angle2);//右指针
    cover2(circle_x, circle_y, circle_r);//覆盖

    key_msg msg;

    //    for (; is_run(); delay_fps(60)) {
    //        msg = getkey();
    //        if (msg.key == key_left && msg.msg == key_msg_down) {
    //            if (angle > 65 * M_PI / 180 || angle < -65 * M_PI / 180) {
    //                if (angle > 65 * M_PI / 180) {
    //                    angle -= 0.015;
    //                }
    //                else {
    //                    angle += 0.015;
    //                }
    //                continue;
    //            }
    //            angle -= 0.015;
    //            cleardevice();
    //            g3(circle_x, circle_y, circle_r);//图形
    //            leftzhizhen1(circle_x, circle_y, circle_r, angle);//左指针
    //            rightzhizhen1(circle_x, circle_y, circle_r, -angle);//右指针
    //            fugai2(circle_x, circle_y, circle_r);//覆盖
    //        }
    //        else if (msg.key == key_right && msg.msg == key_msg_down) {
    //            if (angle > 65 * M_PI / 180 || angle < -65 * M_PI / 180) {
    //                if (angle > 65 * M_PI / 180) {
    //                    angle -= 0.015;
    //                }
    //                else {
    //                    angle += 0.015;
    //                }
    //                continue;
    //            }
    //            angle += 0.015;
    //            cleardevice();
    //            g3(circle_x, circle_y, circle_r);//图形
    //            leftzhizhen1(circle_x, circle_y, circle_r, angle);//左指针
    //            rightzhizhen1(circle_x, circle_y, circle_r, -angle);//右指针
    //            fugai2(circle_x, circle_y, circle_r);//覆盖
    //        }
    //    }//指针旋转
}



void g3(double circle_x, double circle_y, double circle_r) {
    //    setfillcolor(BLACK);//填充色为黑色,不透明
    //    ege_fillrect(circle_x - circle_r * 8 / 6, circle_y - circle_r * 8 / 6, circle_r * 8 / 3, circle_r * 8 / 3);//边框
    //    setfillcolor(EGERGB(100, 100, 100));//填充为灰色
    //    ege_fillrect(circle_x - circle_r * 8 / 6 + circle_r / 60, circle_y - circle_r * 8 / 6 + circle_r / 60, circle_r * 8 / 3 - circle_r / 30, circle_r * 8 / 3 - circle_r / 30);//边框

        //{
        //    ege_point p = { circle_x - circle_r * 21 * 1 / 24 - circle_r / 17 ,circle_y - circle_r * 21 * 0.96 / 24 - circle_r / 17 };
        //    ege_setpattern_ellipsegradient(p, EGERGB(230, 230, 230), circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r * 0.7 / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
        //    ege_fillrect(circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//左上角

        //    ege_point p2 = { circle_x + circle_r * 21 / 24 - circle_r / 17 ,circle_y - circle_r * 21 / 24 - circle_r / 17 };
        //    ege_setpattern_ellipsegradient(p2, EGERGB(230, 230, 230), circle_x + circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
        //    ege_fillrect(circle_x + circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//右上角

        //    ege_point p3 = { circle_x - circle_r * 21 / 24 - circle_r / 17 ,circle_y + circle_r * 21 / 24 - circle_r / 17 };
        //    ege_setpattern_ellipsegradient(p3, EGERGB(230, 230, 230), circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y + circle_r * 21 / 24 - circle_r / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
        //    ege_fillrect(circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y + circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//左下角

        //    ege_point p4 = { circle_x + circle_r * 43 / 48 - circle_r / 17 ,circle_y + circle_r * 21 * 1.02 / 24 - circle_r / 17 };
        //    ege_setpattern_ellipsegradient(p4, EGERGB(230, 230, 230), circle_x + circle_r * 43 / 48 - circle_r / 10, circle_y + circle_r * 21 * 1.01 / 24 - circle_r / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
        //    ege_fillrect(circle_x + circle_r * 43 / 48 - circle_r / 10, circle_y + circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//右下角
        //}//螺丝
    screwc(circle_x, circle_y, circle_r);

    setfillcolor(EGERGB(0, 0, 0));//黑色,不透
    {
        //setcolor(BLACK);//描边颜色
        //setlinewidth(15);//线条粗细
        //ege_circle(circle_x, circle_y, circle_r + circle_r / 10);//描边

        ege_point p5 = { circle_x - circle_r - circle_r / 10 + circle_r / 30 * 11 - circle_r / 4 * 1.4 ,circle_y - circle_r - circle_r / 10 + circle_r / 30 * 11 + circle_r / 2 * 1.5 };
        ege_setpattern_ellipsegradient(p5, EGERGB(190, 190, 190), circle_x - circle_r - circle_r / 10, circle_y - circle_r - circle_r / 10, 2 * (circle_r + circle_r / 10), 2 * (circle_r + circle_r / 10), EGERGB(30, 30, 30));
        ege_fillrect(circle_x - circle_r - circle_r / 10, circle_y - circle_r - circle_r / 10, 2 * (circle_r + circle_r / 10), 2 * (circle_r + circle_r / 10));

    }//最外圈

    {
        ege_point p6 = { circle_x + circle_r + circle_r / 300 * 2 - circle_r / 30 * 10 ,circle_y - circle_r - circle_r / 300 * 2 + circle_r / 30 * 19 };
        ege_setpattern_ellipsegradient(p6, EGERGB(195, 195, 195), circle_x - circle_r - circle_r / 300 * 13, circle_y - circle_r - circle_r / 300 * 13, 2 * (circle_r + circle_r / 300 * 13), 2 * (circle_r + circle_r / 300 * 13), EGEACOLOR(0xFF, 0x373533));
        ege_fillrect(circle_x - circle_r - circle_r / 300 * 13, circle_y - circle_r - circle_r / 300 * 13, 2 * (circle_r + circle_r / 300 * 13), 2 * (circle_r + circle_r / 300 * 13));
        setlinewidth(circle_r / 100 * 4);//线条粗细
        setcolor(EGEACOLOR(0xFF, 0x1B1916));
        ege_circle(circle_x, circle_y, circle_r + circle_r / 25);
    }//第二圈

    {
        setfillcolor(EGEACOLOR(0xFF, 0x211D19));
        ege_fillcircle(circle_x, circle_y, circle_r - circle_r / 10);
        setcolor(BLACK);//线条颜色
        setlinewidth(circle_r / 100);//线条粗细
        ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//描边
    }//第三圈

    {
        setfillcolor(EGEACOLOR(0XFF, 0x33322F));
        setlinewidth( 3);//线条粗细
        setcolor(EGEACOLOR(0XFF, 0x33322F));//线条颜色
        ege_line(circle_x - (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x - (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//左边线
        ege_line(circle_x + (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x + (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//右边线
        ege_circle(circle_x, circle_y, circle_r - circle_r / 10);
        floodfill(circle_x, circle_y, EGEACOLOR(0XFF, 0x33322F));//填充矩形区域
        setcolor(BLACK);//线条颜色
        setlinewidth(2);//线条粗细
        ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//描边
        //2E2A26
        drawScale3(circle_x, circle_y, circle_r);//左边刻度
        drawScale4(circle_x, circle_y, circle_r);//右边刻度
    }//矩形区域

    {
        setcolor(EGERGB(210, 210, 210));
        setbkmode(TRANSPARENT);//去除文字背景色
        setfont(circle_r / 200 * 40, circle_r / 200 * 20, "Arial Bold");
        outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 2, "T");
        outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 4, "E");
        outtextxy((circle_x - circle_r * 0.7), circle_y + circle_r / 45, "M");
        outtextxy((circle_x - circle_r * 0.68), circle_y + circle_r / 4, "P");

        outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 2, "P");
        outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 3.5, "R");
        outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 15, "E");
        outtextxy((circle_x + circle_r * 0.55), circle_y + circle_r / 8, "S");
        outtextxy((circle_x + circle_r * 0.55), circle_y + circle_r / 3.2, "S");

        setfont(circle_r / 200 * 25, circle_r / 200 * 10, "Arial Bold");
        outtextxy((circle_x - circle_r * 0.46), circle_y - circle_r / 20, "°F");
        outtextxy((circle_x + circle_r * 0.42), circle_y - circle_r / 6, "P");
        outtextxy((circle_x + circle_r * 0.42), circle_y - circle_r / 25, "S");
        outtextxy((circle_x + circle_r * 0.44), circle_y + circle_r / 10, "I");
        setfont(circle_r / 200 * 34, circle_r / 200 * 13, "Arial");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((1 * 27 - 70) * M_PI / 180) - circle_r / 15, circle_y + circle_r * 0.72 * sin((1 * 27 - 70) * M_PI / 180) - circle_r / 6, "245");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((2 * 27 - 70) * M_PI / 180) - circle_r / 2.5, circle_y + circle_r * 0.72 * sin((2 * 27 - 70) * M_PI / 180) - circle_r / 70, "200");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((3 * 27 - 70) * M_PI / 180) - circle_r / 2.5, circle_y + circle_r * 0.72 * sin((3 * 27 - 70) * M_PI / 180) - circle_r / 9, "150");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((22.5 * 5 - 67.5) * M_PI / 180) - circle_r / 12, circle_y + circle_r * 0.72 * sin((22.5 * 5 - 67.5) * M_PI / 180) + circle_r / 20, "75");



        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((1 * -22.5 - 112.5) * M_PI / 180) - circle_r / 6, circle_y + circle_r * 0.72 * sin((1 * -22.5 - 112.5) * M_PI / 180) - circle_r / 5.5, "115");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((2 * -15 - 120) * M_PI / 180) + circle_r / 15, circle_y + circle_r * 0.72 * sin((2 * -15 - 120) * M_PI / 180) + circle_r / 20, "100");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((3 * -22.5 - 112.5) * M_PI / 180) + circle_r / 7, circle_y + circle_r * 0.72 * sin((3 * -22.5 - 112.5) * M_PI / 180) - circle_r / 13, "60");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((6 * -15 - 120) * M_PI / 180) + circle_r / 7, circle_y + circle_r * 0.72 * sin((6 * -15 - 120) * M_PI / 180) - circle_r / 5, "20");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((5 * -22.5 - 112.5) * M_PI / 180) - circle_r / 21, circle_y + circle_r * 0.72 * sin((5 * -22.5 - 112.5) * M_PI / 180) + circle_r / 30, "0");

        setfont(circle_r / 200 * 60, circle_r / 200 * 20, "Arial Bold");
        outtextxy(circle_x - circle_r / 7, circle_y + circle_r * 0.6, "OIL");
    }//字
}
// 绘制左边刻度
void drawScale3(double circle_x, double circle_y, double circle_r) {
    setcolor(EGEACOLOR(0XFF, 0x6A8744));//绿色
    setlinewidth(circle_r / 200 * 15);//绿色弧线粗度
    ege_arc((circle_x - circle_r * 0.75) - circle_r * 0.67, circle_y - circle_r * 0.67, 2 * circle_r * 0.67, 2 * circle_r * 0.67, 22.5 - 66, 4 * 22.5 - 6);//绿色弧线
    setcolor(EGERGB(210, 210, 210));//线条颜色
    for (int i = 1; i <= 4; i++) {
        if (i == 1) {
            setcolor(EGEACOLOR(0XFF, 0xA24041));//线条颜色红色
        }
        else {
            setcolor(EGERGB(210, 210, 210));//线条颜色
        }
        double rad = (i * 28 - 70) * M_PI / 180;
        int x1 = (circle_x - circle_r * 0.75) + circle_r * 0.72 * cos(rad);
        int y1 = circle_y + circle_r * 0.72 * sin(rad);
        int x2 = (circle_x - circle_r * 0.75) + circle_r / 1.65 * cos(rad);
        int y2 = circle_y + circle_r / 1.65 * sin(rad);
        setlinewidth(circle_r / 200 * 7);//大线条粗细
        ege_line(x1, y1, x2, y2);
    }
    double rad = (5 * 23 - 65) * M_PI / 180;
    int x1 = (circle_x - circle_r * 0.75) + circle_r * 0.72 * cos(rad);
    int y1 = circle_y + circle_r * 0.72 * sin(rad);
    int x2 = (circle_x - circle_r * 0.75) + circle_r / 1.65 * cos(rad);
    int y2 = circle_y + circle_r / 1.65 * sin(rad);
    setlinewidth(circle_r / 200 * 7);//大线条粗细
    ege_line(x1, y1, x2, y2);
}

// 绘制右边刻度
void drawScale4(double circle_x, double circle_y, double circle_r) {
    setcolor(EGEACOLOR(0XFF, 0x6A8744));//绿色
    setlinewidth(circle_r / 200 * 15);//绿色弧线粗度
    ege_arc((circle_x + circle_r * 0.75) - circle_r * 0.67, circle_y - circle_r * 0.67, 2 * circle_r * 0.67, 2 * circle_r * 0.67, 4 * -18 - 110 - 9, 32);//绿色弧线
    setcolor(EGERGB(210, 210, 210));//线条颜色
    for (int i = 1; i <= 7; i++) {
        if (i == 1 || i == 6) {
            continue;
        }
        double rad = (i * -15.5 - 120) * M_PI / 180;
        int x1 = (circle_x + circle_r * 0.75) + circle_r * 0.72 * cos(rad);
        int y1 = circle_y + circle_r * 0.72 * sin(rad);
        int x2 = (circle_x + circle_r * 0.75) + circle_r / 1.65 * cos(rad);
        int y2 = circle_y + circle_r / 1.65 * sin(rad);
        setlinewidth(circle_r / 200 * 7);//大线条粗细
        ege_line(x1, y1, x2, y2);
    }
    setcolor(EGEACOLOR(0XFF, 0xA24041));//线条颜色红色
    for (int i = 1; i < 7; i += 5) {
        double rad = (i * -15.5 - 122) * M_PI / 180;
        int x1 = (circle_x + circle_r * 0.75) + circle_r * 0.76 * cos(rad);
        int y1 = circle_y + circle_r * 0.76 * sin(rad);
        int x2 = (circle_x + circle_r * 0.75) + circle_r / 1.65 * cos(rad);
        int y2 = circle_y + circle_r / 1.65 * sin(rad);
        setlinewidth(circle_r / 200 * 7);//大线条粗细
        ege_line(x1, y1, x2, y2);
    }
}

//左边指针油温
void leftzhizhen1(double circle_x, double circle_y, double circle_r, double angle) {
    setfillcolor(EGERGB(230, 230, 230));
    ege_point p[] = {
            { 0, 0},
            {circle_r * 0.02, -circle_r * 0.05},
            {circle_r * 0.72 , -circle_r * 0.02},
            {circle_r * 0.72 , circle_r * 0.02},
            {circle_r * 0.02, circle_r * 0.05}
    };
    ege_point px[5] = { 0 };
    for (int i = 0; i < 5; i++) {
        double x = p[i].x;
        double y = p[i].y;
        px[i].x = circle_x - circle_r * 0.75 + x * cos(angle) - y * sin(angle);
        px[i].y = circle_y + x * sin(angle) + y * cos(angle);
    }
    ege_fillpoly(5, px);
}
//右边指针油压
void rightzhizhen1(double circle_x, double circle_y, double circle_r, double angle) {
    setfillcolor(EGERGB(230, 230, 230));
    ege_point p[] = {
            { 0, 0},
            {-circle_r * 0.02, -circle_r * 0.05},
            {-circle_r * 0.72 , -circle_r * 0.02},
            {-circle_r * 0.72 , circle_r * 0.02},
            {-circle_r * 0.02, circle_r * 0.05}
    };
    ege_point px[5] = { 0 };
    for (int i = 0; i < 5; i++) {
        double x = p[i].x;
        double y = p[i].y;
        px[i].x = circle_x + circle_r * 0.75 + x * cos(angle) - y * sin(angle);
        px[i].y = circle_y + x * sin(angle) + y * cos(angle);
    }
    ege_fillpoly(5, px);
}
void cover2(double circle_x, double circle_y, double circle_r) {

    setfillcolor(EGEACOLOR(0XFF, 0x211D19));
    setlinewidth(3);//线条粗细
    setcolor(EGEACOLOR(0XFF, 0x211D19));//线条颜色
    ege_line(circle_x - (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x - (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//左边线
    ege_line(circle_x + (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x + (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//右边线
    ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//闭合
    floodfill(circle_x - circle_r * 0.73, circle_y, EGEACOLOR(0XFF, 0x211D19));//填充矩形区域
    floodfill(circle_x + circle_r * 0.73, circle_y, EGEACOLOR(0XFF, 0x211D19));//填充矩形区域

    {
        setlinewidth( 3);//线条粗细
        setcolor(EGEACOLOR(0XFF, 0x33322F));//线条颜色
        ege_line(circle_x - (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x - (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//左边线
        ege_line(circle_x + (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x + (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//右边线
        setcolor(BLACK);//线条颜色
        setlinewidth(2);//线条粗细
        ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//描边
    }//复原

    setcolor(EGERGB(210, 210, 210));
    setbkmode(TRANSPARENT);//去除文字背景色
    setfont(circle_r / 200 * 40, circle_r / 200 * 20, "Arial Bold");
    outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 2, "T");
    outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 4, "E");
    outtextxy((circle_x - circle_r * 0.7), circle_y + circle_r / 45, "M");
    outtextxy((circle_x - circle_r * 0.68), circle_y + circle_r / 4, "P");

    outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 2, "P");
    outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 3.5, "R");
    outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 15, "E");
    outtextxy((circle_x + circle_r * 0.55), circle_y + circle_r / 8, "S");
    outtextxy((circle_x + circle_r * 0.55), circle_y + circle_r / 3.2, "S");
}
void screwc(double centerX, double centerY, double dialRadius)
{
    // 使用float保证计算精度（根据需求可改为double）
    const float DIAL_RADIUS_F = (float)dialRadius;
    const float CENTER_X_F = (float)centerX;
    const float CENTER_Y_F = (float)centerY;

    // 参数化定义（精确到小数点后6位）
    const float SCREW_OFFSET = DIAL_RADIUS_F * 0.055555556f; // 1/18
    const float ELLIPSE_OFFSET_X = -DIAL_RADIUS_F * 0.111111111f; // -1/9
    const float ELLIPSE_OFFSET_Y = -DIAL_RADIUS_F * 0.166666667f; // -1/6
    const float ELLIPSE_SIZE = DIAL_RADIUS_F * 0.277777778f;  // 5/18
    const float RECT_OFFSET_X = DIAL_RADIUS_F * 0.222222222f;  // 2/9
    const float RECT_OFFSET_Y = DIAL_RADIUS_F * 0.333333333f;  // 1/3
    const float RECT_WIDTH = DIAL_RADIUS_F * 0.555555556f;   // 5/9
    const float RECT_HEIGHT = DIAL_RADIUS_F * 0.611111111f;  // 11/18
    const float CROSS_OFFSET1 = DIAL_RADIUS_F * 0.055555556f;  // 1/18
    const float CROSS_OFFSET2 = DIAL_RADIUS_F * 0.027777778f;  // 1/36
    const float LINE_WIDTH = DIAL_RADIUS_F * 0.016666667f;  // 1/60

    ege_enable_aa(TRUE);

    // 绘制函数（使用浮点坐标）
    auto draw_screw = [&](float cx, float cy) {
        // 精确到小数点后6位的渐变参数
        ege_setpattern_ellipsegradient(
            ege_point{ roundf(cx), roundf(cy) }, // 最终转整数
            EGEACOLOR(0xFF, BLACK),
            roundf(cx + ELLIPSE_OFFSET_X),
            roundf(cy + ELLIPSE_OFFSET_Y),
            roundf(ELLIPSE_SIZE),
            roundf(ELLIPSE_SIZE),
            EGEACOLOR(0, WHITE)
        );
        ege_fillrect(
            roundf(cx - RECT_OFFSET_X),
            roundf(cy - RECT_OFFSET_Y),
            roundf(RECT_WIDTH),
            roundf(RECT_HEIGHT)
        );

        // 灰色渐变层（精确尺寸调整）
        const float adjusted_size = ELLIPSE_SIZE - DIAL_RADIUS_F * 0.055555556f; // 替代原-10
        ege_setpattern_ellipsegradient(
            ege_point{
              roundf(cx - SCREW_OFFSET * 0.5f),
                roundf(cy - SCREW_OFFSET * 0.5f)
            },
            EGEACOLOR(0xFF, EGERGB(170, 170, 170)),
            roundf(cx + ELLIPSE_OFFSET_X),
            roundf(cy + ELLIPSE_OFFSET_Y),
            roundf(adjusted_size),
            roundf(adjusted_size),
            EGEACOLOR(0xFF, EGERGB(20, 20, 20))
        );
        ege_fillrect(
            roundf(cx - RECT_OFFSET_X),
            roundf(cy - RECT_OFFSET_Y),
            roundf(RECT_WIDTH),
            roundf(RECT_HEIGHT)
        );

        // 十字线（亚像素级精度）
        setcolor(EGERGB(30, 30, 30));
        setlinewidth(roundf(LINE_WIDTH));

        const float cross_y = cy - CROSS_OFFSET2 * 2.0f;
        ege_line(
            roundf(cx - CROSS_OFFSET1), roundf(cross_y),
            roundf(cx + CROSS_OFFSET1), roundf(cross_y)
        );

        const float cross_x = cx;
        const float cross_y_start = cy + CROSS_OFFSET2 / 4;
        const float cross_y_end = cy - CROSS_OFFSET2 * 4.0f;
        ege_line(
            roundf(cross_x), roundf(cross_y_start),
            roundf(cross_x), roundf(cross_y_end)
        );
        };

    // 计算四个螺丝中心坐标（浮点运算）
    const float screw_radius = DIAL_RADIUS_F - SCREW_OFFSET;

    // 左上
    draw_screw(
        CENTER_X_F - screw_radius,
        CENTER_Y_F - DIAL_RADIUS_F
    );

    // 右上
    draw_screw(
        CENTER_X_F + screw_radius,
        CENTER_Y_F - DIAL_RADIUS_F
    );

    // 右下
    draw_screw(
        CENTER_X_F + screw_radius,
        CENTER_Y_F + DIAL_RADIUS_F
    );

    // 左下（新增）
    draw_screw(
        CENTER_X_F - screw_radius,
        CENTER_Y_F + DIAL_RADIUS_F
    );
}